#ifndef __GLOBAL_H
#define __GLOBAL_H

#include "stm32f10x-board.h"
#include "structs.h"
#include "ff.h"

#define TRUE  1
#define FALSE 0

#define INVALID_VALUE_INT (-1)

#define     NotBit(x,y)             ((x)^=(1<<(y)))             //???
#define     SetBit(x,y)             ((x) |= (1<<(y)))
#define     ClrBit(x,y)             ((x) &= ~(1<<(y)))
#define     TestBit(x,y)            (((x)>>(y))&(0x01))

#define EnumToString(x) return (#x);


#define MAX_FILE_NAME_SZ 80          //最大文件名长度

extern FATFS fs;
extern FIL fid;


//enum MAINMENU
//{
//    Start_Gcode = 0,
//    Manual_Mode,
//    Show_Gcode,
//    File_System,
//    Set_Time,
//    Scan_Mode,
//    Param_Set,
//    Touch_Set
//};



static __INLINE uint8_t limitX_chk(void)
{
    return ((LIMIT_X_PORT->IDR & LIMIT_X_PIN) == LIMIT_X_STATE ? 1 : 0);
}


static __INLINE uint8_t limitY_chk(void)
{
    return ((LIMIT_Y_PORT->IDR & LIMIT_Y_PIN) == LIMIT_Y_STATE ? 1 : 0);
}

static __INLINE uint8_t limitZ_chk(void)
{
    return ((LIMIT_Z_PORT->IDR & LIMIT_Z_PIN) == LIMIT_Z_STATE ? 1 : 0);
}

static __INLINE uint8_t limits_chk(void)
{
    return 0;
    //    return limitX_chk() || limitY_chk() || limitZ_chk();
}


#define SYS_NO_ACTION   0
#define SYS_READ_FLASH  1

#include "screen_io.h"
#include "ff.h"
//#include "keyboard.h"
#include "stepmotor.h"
#include "extruder_t.h"

extern SM_PARAM _smParam;
extern int8_t LR_KEY;

#endif


